package com.example.seckillweb.config;

import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: TODO
 * @author: uu
 * @date: 2023/12/21 21:00
 * @version: 1.0
 */
@Configuration
public class RedissonConfig {
    @Value("${spring.data.redis.host}")
    private String redis_host;

    @Value("${spring.data.redis.port}")
    private Integer redis_port;
    @Bean
    public Redisson redisson(){
        Config config = new Config();
        String url = "redis://" + redis_host + ":" + redis_port;
//        System.out.println("url : "  + url);
        config.useSingleServer()
                        .setAddress(url)
                        .setDatabase(0);

        return ((Redisson) Redisson.create(config));
    }
}
